package com.nekonomics
package api.dto.response

import domain.detail.TopN
import types.Money

import zio.json.JsonEncoder

case class TopNDto(
  spuId: Long,
  spuName: String,
  totalSales: Money,
  rank: Int
) derives JsonEncoder


object TopNDto {


  given Ordering[TopNDto] = Ordering.by(_.rank)

  def of(topN: TopN) = TopNDto(
    spuId = topN.spuId,
    spuName = topN.productName,
    totalSales = topN.productSales,
    rank = topN.productRank
  )


}
